package cn.edu.nju.software.gui;

import javax.swing.*;

import cn.edu.nju.software.net.Connection;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class Share extends JPanel implements ActionListener{
	
	Connection connection; 
	ManagerOperation mo;
	
	
	public Share(ManagerOperation newMO){
		super();
		mo = newMO;
		connection = Connection.getInstance();
		
		
	    JButton shareButton = new JButton("Share");
	    shareButton.addActionListener(new ActionListener(){

			@Override
			public void actionPerformed(ActionEvent e) {
				if(connection.handleShareCourse())
					JOptionPane.showMessageDialog(null, "Share successfully");
				else
					JOptionPane.showMessageDialog(null, "Fail to share");
				// TODO Auto-generated method stub
				
			}
	    	
	    });
	    add(shareButton);
                 }

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		connection.handleShareCourse();
		
	}
	}
